Skip to content

Add create_discussion tool to discussions toolset#1519

Open
furkankoykiran wants to merge 1 commit intogithub:mainfrom
furkankoykiran:feature/add-create-discussion-tool
Open

Add create_discussion tool to discussions toolset#1519
furkankoykiran wants to merge 1 commit intogithub:mainfrom
furkankoykiran:feature/add-create-discussion-tool

Conversation

@furkankoykiran
Copy link

Closes #1517

This PR adds a new create_discussion tool to the discussions toolset, enabling programmatic creation of GitHub Discussions through the MCP server.

Changes

  • Added CreateDiscussion function in pkg/github/discussions.go using GraphQL mutation
  • Implemented comprehensive unit tests covering success and error scenarios
  • Updated discussions toolset to include the new write tool
  • Generated toolsnap for schema validation

Testing

  • All existing tests pass
  • New tests cover:
    • Successful discussion creation
    • Organization-level discussions
    • Missing parameter validation
    • Repository and category not found errors
  • Linter passes with no issues
  • Documentation generated via script/generate-docs

The tool follows existing patterns in the codebase and integrates cleanly with the current discussions toolset structure.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new create_discussion tool to enable programmatic creation of GitHub Discussions through the MCP server. The implementation uses GraphQL mutations and follows existing patterns in the codebase for write operations.

Key changes:

  • New CreateDiscussion function using GraphQL mutation API
  • Registration of the tool in the discussions toolset as a write tool
  • Comprehensive unit tests covering various scenarios
  • Generated toolsnap for API schema validation

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/github/discussions.go Implements the CreateDiscussion function with GraphQL mutation, parameter validation, and error handling. Supports both repository-level and organization-level discussions (via .github repo).
pkg/github/tools.go Registers CreateDiscussion as a write tool in the discussions toolset.
pkg/github/discussions_test.go Adds comprehensive unit tests covering successful creation, organization-level discussions, missing parameters, and error scenarios (repository/category not found).
pkg/github/toolsnaps/create_discussion.snap Tool schema snapshot for API validation (needs regeneration after fixing ReadOnlyHint issue).
README.md Updates tool documentation with the new create_discussion tool and its parameters.
docs/remote-server.md Changes "Default" to "all" in the toolset table (appears unrelated to this PR).

{
"annotations": {
"title": "Create discussion"
},
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The toolsnap is missing the readOnlyHint field that should be set to false for write operations. This needs to be regenerated after adding ReadOnlyHint: false to the tool annotations in discussions.go. Run UPDATE_TOOLSNAPS=true go test ./... to update the snapshot after fixing the code.

Suggested change
},
},
"readOnlyHint": false,

Copilot uses AI. Check for mistakes.
| Name | Description | API URL | 1-Click Install (VS Code) | Read-only Link | 1-Click Read-only Install (VS Code) |
|----------------|--------------------------------------------------|-------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Default | ["Default" toolset](../README.md#default-toolset) | https://api.githubcopilot.com/mcp/ | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) | [read-only](https://api.githubcopilot.com/mcp/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Freadonly%22%7D) |
| all | All available GitHub MCP tools | https://api.githubcopilot.com/mcp/ | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) | [read-only](https://api.githubcopilot.com/mcp/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Freadonly%22%7D) |
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change from "Default" to "all" appears to be unrelated to adding the create_discussion tool. If this is an intentional update to the remote server documentation, it should be in a separate commit or PR. Otherwise, this line should remain as "Default" to match line 91 which still references "Default toolset".

Suggested change
| all | All available GitHub MCP tools | https://api.githubcopilot.com/mcp/ | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) | [read-only](https://api.githubcopilot.com/mcp/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Freadonly%22%7D) |
| Default | All available GitHub MCP tools | https://api.githubcopilot.com/mcp/ | [Install](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) | [read-only](https://api.githubcopilot.com/mcp/readonly) | [Install read-only](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2Freadonly%22%7D) |

Copilot uses AI. Check for mistakes.
Name: "create_discussion",
Description: t("TOOL_CREATE_DISCUSSION_DESCRIPTION", "Create a new discussion in a repository or organisation."),
Annotations: &mcp.ToolAnnotations{
Title: t("TOOL_CREATE_DISCUSSION_USER_TITLE", "Create discussion"),
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ReadOnlyHint: false annotation. Write operations like create_discussion should explicitly set ReadOnlyHint: false to indicate they perform mutations. This is consistent with other write tools in the codebase (see create_gist, label_write, create_issue, etc.).

Suggested change
Title: t("TOOL_CREATE_DISCUSSION_USER_TITLE", "Create discussion"),
Title: t("TOOL_CREATE_DISCUSSION_USER_TITLE", "Create discussion"),
ReadOnlyHint: mcp.BoolPtr(false),

Copilot uses AI. Check for mistakes.
Comment on lines 820 to 831
require.NoError(t, toolsnaps.Test(toolDef.Name, toolDef))

assert.Equal(t, "create_discussion", toolDef.Name)
assert.NotEmpty(t, toolDef.Description)
schema, ok := toolDef.InputSchema.(*jsonschema.Schema)
require.True(t, ok, "InputSchema should be *jsonschema.Schema")
assert.Contains(t, schema.Properties, "owner")
assert.Contains(t, schema.Properties, "repo")
assert.Contains(t, schema.Properties, "categoryId")
assert.Contains(t, schema.Properties, "title")
assert.Contains(t, schema.Properties, "body")
assert.ElementsMatch(t, schema.Required, []string{"owner", "categoryId", "title", "body"})
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test should verify that ReadOnlyHint is false for the write tool, similar to how other write tool tests do (e.g., create_gist, label_write). Add:

assert.False(t, toolDef.Annotations.ReadOnlyHint, "create_discussion tool should not be read-only")

Copilot uses AI. Check for mistakes.
This PR adds a new CreateDiscussion tool that allows users to create
discussions in a GitHub repository or at the organisation level.

Changes:
- Add CreateDiscussion function with new NewTool() pattern in discussions.go
- Add getDiscussionRepositoryID helper function
- Add comprehensive unit tests in discussions_test.go
- Add toolsnap for create_discussion tool
@furkankoykiran furkankoykiran force-pushed the feature/add-create-discussion-tool branch from e02cd14 to e854a95 Compare February 4, 2026 10:49
@furkankoykiran
Copy link
Author

Hey @SamMorrowDrums 👋

Just wanted to give a heads up - I've rebased this PR on latest main to fix the conflicts that came up after all the recent refactoring.

Had to reimplement the whole thing using the new NewTool() pattern since the codebase changed quite a bit since December. Everything should be good now with the updated tests and toolsnap.

Would appreciate a review when you get a chance! Let me know if anything needs adjustment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add create_discussion tool to discussions toolset

1 participant